<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{ repData }}</h1>
    </div>

    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vue-resource/dist/vue-resource.js"></script>

    <script>
        var vm = new Vue({
            el:'#app',
            data:{
                repData: []
            },
            created() {
                // GET /someUrl
                this.$http.get('http://127.0.0.1:5500/vue-07-lifecycle&ajax/db.json').then(response => { // function(response) {}
                    // 回调函数需要使用箭头函数（this Vue实例），不然this代表window
                    console.log(response.data)
                    this.repData = response.data
                }, response => {
                    // error callback
                    console.log(response.statusText, response.status)
                });
            },
        })
    </script>
</body>
</html>